function minMutation(start: string, end: string, bank: string[]): number {
  const m: Map<string, number> = new Map();
  const s: Set<string> = new Set();
  m.set(start, 0);
  for (let str of bank) s.add(str);
  if (!s.has(end)) return -1;
  const q: string[] = [start];
  const gene = ['A', 'C', 'G', 'T'];
  while (q.length) {
    const strArr = q.shift();
    for (let i = 0; i < 8; i++) {
      for (let j = 0; j < 4; j++) {
        if (strArr[i] !== gene[j]) {
          const backup = strArr.split('');
          backup[i] = gene[j];
          const backupStr = backup.join('');
          if (!s.has(backupStr)) continue;
          if (m.has(backupStr)) continue;
          m.set(backupStr, (m.get(strArr) || 0) + 1);
          q.push(backupStr);
          if (backupStr === end) return m.get(backupStr);
        }
      }
    }
  }
  return -1;
};